﻿<%@ Page Title="" Language="C#" MasterPageFile="/Common/Master.master" %>

<script runat="server">

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentForm" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentHtml" runat="Server">
    <div class="easyui-layout tableEdit" data-options="fit:true,border:false">
        <div data-options="region:'center',border:false" id="validation" class="validationEngineContainer">
            <div class="z_wrap">
                <ul class="info">
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='id' name='id' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='pid' name='pid' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='grade' name='grade' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='levels' name='levels' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='leaf' name='leaf' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='state' name='state' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='disable' name='disable' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='name' name='name' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='value' name='value' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='url' name='url' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='isdel' name='isdel' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='adduserid' name='adduserid' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='lastuserid' name='lastuserid' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='addtime' name='addtime' type='text' class='Wdate validate[required]' onclick='WdatePicker()' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='lasttime' name='lasttime' type='text' class='Wdate validate[required]' onclick='WdatePicker()' data-prompt-position='bottomRight' /></div>
                    </li>
                </ul>
            </div>
        </div>
        <div data-options="region:'south'" style="height: 35px; border-bottom: 0px; border-left: 0px; border-right: 0px;" class="edit_bottom">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-save'" id="buttonOk">确 定</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$.layerClose(false);">取 消</a>
        </div>
    </div>

    <script type="text/javascript">
        $(function () {
            jQuery('#validation').validationEngine();

            $("#buttonOk").click(function () {
                InsertOrUpdate();
            });
            if ($.getUrlParamer("guid") != "") {
                DataBind();
            }
        });

        function DataBind() {
            $.InvokeAjax({
                url: "Api/V1/system_wechat/Getwechat",
                data: { ID: $.getUrlParamer("guid") },
                callBack: function (data) {
                    var obj = $.StrToJson(data).Results;

                    $.SetValue("id", obj.id);
                    $.SetValue("pid", obj.pid);
                    $.SetValue("grade", obj.grade);
                    $.SetValue("levels", obj.levels);
                    $.SetValue("leaf", obj.leaf);
                    $.SetValue("state", obj.state);
                    $.SetValue("disable", obj.disable);
                    $.SetValue("name", obj.name);
                    $.SetValue("value", obj.value);
                    $.SetValue("url", obj.url);
                    $.SetValue("isdel", obj.isdel);
                    $.SetValue("adduserid", obj.adduserid);
                    $.SetValue("lastuserid", obj.lastuserid);
                    $.SetValue("addtime", $.DateFormat(obj.addtime, 'yyyy-MM-dd HH:mm:ss'));
                    $.SetValue("lasttime", $.DateFormat(obj.lasttime, 'yyyy-MM-dd HH:mm:ss'));

                }
            });
        }

        function InsertOrUpdate() {
            if (!$('#validation').validationEngine('validate')) { return false; }
            var url = $.getUrlParamer("guid") != "" ? "Api/V1/system_wechat/Updatewechat" : "Api/V1/system_wechat/Addwechat";

            var obj = { ID: $.getUrlParamer("guid") };
            obj.id = $.GetValue("id");
            obj.pid = $.GetValue("pid");
            obj.grade = $.GetValue("grade");
            obj.levels = $.GetValue("levels");
            obj.leaf = $.GetValue("leaf");
            obj.state = $.GetValue("state");
            obj.disable = $.GetValue("disable");
            obj.name = $.GetValue("name");
            obj.value = $.GetValue("value");
            obj.url = $.GetValue("url");
            obj.isdel = $.GetValue("isdel");
            obj.adduserid = $.GetValue("adduserid");
            obj.lastuserid = $.GetValue("lastuserid");
            obj.addtime = $.JsonDateFy($.GetValue("addtime") == "自动" ? $.GetDateTime() : $.GetValue("addtime"));
            obj.lasttime = $.JsonDateFy($.GetValue("lasttime") == "自动" ? $.GetDateTime() : $.GetValue("lasttime"));


            $.InvokeAjax({
                url: url,
                data: obj,
                callBack: function (data) {
                    $.layerClose(true);
                }
            });
        }
    </script>
</asp:Content>
